/* File: OnlyConnect.cpp
 *
 * TODO: Edit these comments to describe anything interesting or noteworthy in your implementation.
 *
 * TODO: Edit these comments to leave a puzzle for your section leader to solve!
 */
#include "OnlyConnect.h"
#include "GUI/SimpleTest.h"

#include <cctype>
#include <strlib.h>

using namespace std;

/*
 * 判断参数 c 是否辅音字母，
 * 是辅音，返回 true；其他，返回false
 */
bool isConsonant(char c) {
    if (!isalpha(c)) {
        return false;
    }
    
    if (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') {
        return false;
    }
    return true;
}

string remainConsonant(char c) {
    string s = "";
    if (isConsonant(c)) {
        s += c;
    }
    return s;
}

string onlyConnectize(string phrase) {
    // 全部转大写
    phrase = toUpperCase(phrase);
    if (phrase.length() < 1) {
        return "";
    }
    // string s1 = remainConsonant(phrase[0]);
    // string s2 = onlyConnectize(phrase.substr(1));
    return remainConsonant(phrase[0]) + onlyConnectize(phrase.substr(1));
}


/* * * * * * Provided Test Cases * * * * * */

PROVIDED_TEST("Converts lower-case to upper-case.") {
    EXPECT_EQUAL(onlyConnectize("lowercase"), "LWRCS");
    EXPECT_EQUAL(onlyConnectize("uppercase"), "PPRCS");
}

PROVIDED_TEST("Handles non-letter characters properly.") {
    EXPECT_EQUAL(onlyConnectize("2.718281828459045"), "");
    EXPECT_EQUAL(onlyConnectize("'Hi, Mom!'"), "HMM");
}

PROVIDED_TEST("Handles single-character inputs.") {
    EXPECT_EQUAL(onlyConnectize("A"), "");
    EXPECT_EQUAL(onlyConnectize("+"), "");
    EXPECT_EQUAL(onlyConnectize("Q"), "Q");
}

STUDENT_TEST("所有元音字母") {
    EXPECT_EQUAL(onlyConnectize("a"), "");
    EXPECT_EQUAL(onlyConnectize("e"), "");
    EXPECT_EQUAL(onlyConnectize("i"), "");
    EXPECT_EQUAL(onlyConnectize("o"), "");
    EXPECT_EQUAL(onlyConnectize("u"), "");
    EXPECT_EQUAL(onlyConnectize("A"), "");
    EXPECT_EQUAL(onlyConnectize("E"), "");
    EXPECT_EQUAL(onlyConnectize("I"), "");
    EXPECT_EQUAL(onlyConnectize("O"), "");
    EXPECT_EQUAL(onlyConnectize("U"), "");
}

STUDENT_TEST("数字") {
    EXPECT_EQUAL(onlyConnectize("1234567890"), "");
}

STUDENT_TEST("字母表") {
    EXPECT_EQUAL(onlyConnectize("abcdefghijklmnopqrstuvwxyz"), "BCDFGHJKLMNPQRSTVWXYZ");
}

STUDENT_TEST("极端情况") {
    EXPECT_EQUAL(onlyConnectize(""), "");
}

/* TODO: You will need to add your own tests into this suite of test cases. Think about the sorts
 * of inputs we tested here, and, importantly, what sorts of inputs we *didn't* test here. Some
 * general rules of testing:
 *
 *    1. Try extreme cases. What are some very large cases to check? What are some very small cases?
 *
 *    2. Be diverse. There are a lot of possible inputs out there. Make sure you have tests that account
 *       for cases that aren't just variations of one another.
 *
 *    3. Be sneaky. Don't just try standard inputs. Try weird ones that you wouldn't expect anyone to
 *       actually enter, but which are still perfectly legal.
 *
 * Happy testing!
 */






